﻿Imports System.Collections.Generic

Imports Microsoft.VisualStudio.TestTools.UnitTesting

Imports Microsoft.DPE.Samples.PictureProvider

Imports Microsoft.DPE.Samples.PictureProvider.Tests.Mocks


<TestClass()> _
Public Class PictureManagerFixture

    <TestMethod()> _
   Public Sub TestGetPictureByIdIsCallingProvider()
        Dim provider As MockPictureProvider = DirectCast(PictureManager.Provider, MockPictureProvider)
        Assert.IsFalse(provider.GetPictureByIdCalled)
        PictureManager.GetPictureById("TDD")
        Assert.IsTrue(provider.GetPictureByIdCalled)
    End Sub

    <TestMethod()> _
    Public Sub TestGetPicturesIsCallingProvider()
        Dim provider As MockPictureProvider = DirectCast(PictureManager.Provider, MockPictureProvider)
        Assert.IsFalse(provider.GetPicturesCalled)
        PictureManager.GetPictures()
        Assert.IsTrue(provider.GetPicturesCalled)
    End Sub

    <TestMethod()> _
    Public Sub TestGetPicturesByTagIsCallingProvider()
        Dim provider As MockPictureProvider = DirectCast(PictureManager.Provider, MockPictureProvider)
        Assert.IsFalse(provider.GetPicturesByTagCalled)
        PictureManager.GetPicturesByTag("TDD")
        Assert.IsTrue(provider.GetPicturesByTagCalled)
    End Sub

    <TestMethod(), ExpectedException(GetType(ArgumentNullException))> _
    Public Sub TestGetPictureByIdIsThrowingException()
        PictureManager.GetPictureById(String.Empty)
    End Sub

    <TestMethod(), ExpectedException(GetType(ArgumentNullException))> _
    Public Sub TestGetPictureByIdIsThrowingException2()
        PictureManager.GetPictureById(Nothing)
    End Sub

    <TestMethod(), ExpectedException(GetType(ArgumentNullException))> _
    Public Sub TestGetPicturesByTagIsThrowingException()
        PictureManager.GetPicturesByTag(String.Empty)
    End Sub

    <TestMethod(), ExpectedException(GetType(ArgumentNullException))> _
    Public Sub TestGetPicturesByTagIsThrowingException2()
        PictureManager.GetPicturesByTag(Nothing)
    End Sub

End Class

